<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>用户订单记录</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

	<!-- 自动查找引入进来的工具类脚本。 -->
	<link rel="stylesheet" href="./layui/css/layui.css"  media="all">
</head>
<body>
<!-- 抬头 -->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
	<legend>用户订单记录</legend>
</fieldset>
<!-- 用户信息栏 -->
<ul class="layui-nav">
<li class="layui-nav-item" lay-unselect="">
	<!-- <a href="javascript:;">当前账号
		<img src="//t.cn/RCzsdCq" class="layui-nav-img"></img>
	</a> -->
	<label class="layui-form-label" style="padding:7.5px 0px;">当前账号</label>
	<label class="layui-form-label" id='userID' style="padding:7.5px 0px;"></label>
</li>
<li class="layui-nav-item" lay-unselect="">
		<a href="javascript:void(0)" onclick="gotoPlaceOrder();" target='topFrame'>[用户充值下单系统]</a>
</li>
</ul>
<!-- 表格显示栏 -->
<table class="layui-hide" id="test" lay-filter="test"></table>
<!-- 自动查找引入进来的工具类脚本。 -->
<script src="./layui/layui.js" charset="utf-8"></script>

<script>
layui.config({
	version: true
}).use(['layer','table','mobile'], function(){
	var ws = new WebSocket("ws://192.168.1.116:8080");
	// 连接成功
	ws.onopen = function (e) {
		console.log('连接成功获取到的上半段脚本定义的用户id和客服id=',selfid);
		ws.send(JSON.stringify({
			type: 'REGISTER', 	// 随便定义，用于在服务端区分消息类型
			selfid: selfid,		// 写入自身id
		})); 
	}
	// 连接关闭
	// ws.onclose = function (e) {
	// 	console.log('连接关闭');
	// }
	var mobile = layui.mobile;
		table = layui.table,
        layer = layui.layer,
		$= layui.jquery;
	document.getElementById('userID').innerHTML = selfid;
	
	var data_index = {"id":selfid};
	$.post("/order_status",data_index,function(result){
		if(result.status == "success"){
			layer.msg('成功打开订单数据');	// 弹出提示
			console.log(result.order_data,'有数据吗');
			table.render({
				elem: '#test',
				title: '订单记录',
				totalRow: true,
				cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
				cols: [[
					{field:'orderNum', width:80, title:'订单号'},
					{field:'orderTime', width:80, title:'下单时间', sort: true},
					{field:'orderId', width:80, title:'下单账号'},
					{field:'orderType_getMoney', width:80, title:'收/付款账号'},
					{field:'orderCount', width:80, title:'账号对应姓名'},
					{field:'orderType_yewu', width:80, title:'业务类型'},
					{field:'orderAmount', width:80, title:'订单金额', sort: true},
      				{field:'orderStatus', width:80, title:'订单状态'},
				]],
				data: [{
					orderNum:001,
					orderTime:15645454,
					orderId:1234567,
					orderType_getMoney:1234567,
					orderCount:1234567,
					orderType_yewu:1234567,
					orderAmount:1234567,
					orderStatus:0,
				}],		// 数据赋值
				page: true,
			});
		}
		else{
			layer.msg("错误信息:"+result.order_data);
		}
	});
});

function gotoPlaceOrder(){
	console.log('点击返回用户充值下单页面')
	location.href="/?selfid="+selfid;
}
</script>
</body>
</html>
